<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // 局部变量
    // 1. 在函数内通过关键词var let const声明的变量 
    // 2. 形式参数也是局部变量  

    // 作用域: 代码生效的区域
    // 局部变量只在函数内生效  => 局部作用域(函数作用域)

   /*  function add(){
        var a = 1;
        var b = 2;
        var c = a + b;
        console.log("函数内",c);
        return c;
    }
    var result = add();
    console.log(result);
    console.log(c);  // c is not defined */



    function add(a,b){
        // var a = 10,b = 20;

        var c = a + b;
        console.log("函数内",a,b,c);
        return c;
    }
    var result = add(10,20);
    console.log(result);
    console.log(a);  // c is not defined
    console.log(b);  // c is not defined
    console.log(c);  // c is not defined





</script>
</html>